//
//  YWMeterReadingDBManager.h
//  maintain
//
//  Created by kyo on 16/11/8.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YWSingleton.h"

#import "YWMeterReadingRecord.h"

@interface YWMeterReadingDBManager : NSObject
YWSingletonH(Manager)

/**
 *  创建抄表记录表
 *
 *  @return 结果
 */
- (BOOL)createMeterReadingRecordTable;
- (BOOL)createNetWorkMeterReadingRecordTable;
- (BOOL)createThisMonthReadMeterCountTable;
/**
 *  保存(本地)抄表记录
 *
 *  @param records 抄表记录模型数组
 *
 *  @return 结果
 */
- (BOOL)updateMeterReadingRecordWithRecordArray:(NSArray*)records;
/**
 *  保存(网络)抄表记录
 *
 *  @param records 抄表记录模型数组
 *
 *  @return 结果
 */
- (BOOL)updateNetWorkMeterReadingRecordWithRecordArray:(NSArray*)records;


/**
 *  保存抄表记录
 *
 *  @param record 抄表记录模型
 *
 *  @return 结果
 */
- (BOOL)updateMeterReadingRecordWithRecord:(YWMeterReadingRecord*)record;
/**
 *  (水，电，燃气)抄表记录
 *
 *  @param meterEquipmentType 设备类型
 *
 *  @return 结果
 */
- (NSArray*)meterReadingRecordWithEquipmentType:(NSInteger)meterEquipmentType page:(NSInteger)page;
/**
 *  (水，电，燃气)抄表记录
 *
 *  @param recordId 记录id
 *
 *  @return 结果
 */
- (YWMeterReadingRecord*)meterReadingRecordWithRecordId:(NSString*)recordId;
/**
 *  本地某设备最新一条抄表记录
 *
 *  @param equipmentId 设备id
 *
 *  @return 结果
 */
- (YWMeterReadingRecord*)latestMeterReadingRecordWithEquipmentId:(NSString*)equipmentId;
/**
 *  修改抄表记录的id
 *
 *  @param record 抄表记录模型
 *  @param recordId 抄表记录ID
 *
 *  @return 结果
 */
- (BOOL)modifyMeterReadingRecordIdWithRecord:(YWMeterReadingRecord*)record recordId:(NSString*)recordId;
/**
 *  更新抄表记录的上传状态
 *
 *  @param uploadStatus  上传状态
 *  @param recordId 记录id
 *
 *  @return 结果
 */
- (BOOL)updateMeterReadingRecordUploadStatus:(YWMeterReadingRecordUploadStatus)uploadStatus recordId:(NSString*)recordId;
/**
 *  删除抄表记录数据
 *
 *  @param meterEquipmentType 类型id
 *
 *  @return 结果
 */
- (BOOL)deleteMeterReadingRecordWithEquipmentType:(NSInteger)meterEquipmentType;
/**
 *  获取上传失败的抄表记录
 *
 *  @return 抄表模型数组
 */
- (NSArray*)meterReadingRecordWithUploadStatusFail;

/**
 *  保存楼盘当月已抄表数量
 *
 *  @param jsons json对象
 *
 *  @return 结果
 */
- (BOOL)saveThisMonthReadMeterCountWithJson:(NSArray*)jsons;
;
/**
 *  获取所有楼盘当月已抄表数量
 *
 *  @param equipmenttypeId 仪表类型Id
 *
 *  @return  数组
 
 */
- (NSArray*)allThisMonthReadMeterCount:(NSInteger)equipmenttypeId;
/**
 *  获取今天的抄表数
 *
 *  @param equipmentTypeId 设备类型Id
 *
 *  @return 数量
 */
- (NSInteger)toDayReadMeterCountWithEquipmentTypeId:(NSInteger)equipmentTypeId;
/**
 *  修改抄表记录读数
 *
 *  @param record 抄表记录model
 *
 *  @return 结果
 */
- (BOOL)modifyReadNumberOfMeterReadingRecord:(YWMeterReadingRecord*)record;
@end
